// JavaScript Document

var req=null;
var console=null;
var READY_STATE_UNINITIALIZED=0;
var READY_STATE_LOADING=1;
var READY_STATE_LOADED=2;
var READY_STATE_COMPLETE = 4; 
function hideShowDiv(idToHide,idToShow){
			document.getElementById(idToHide).style.display='none';
			document.getElementById(idToShow).style.display='';
	}
	
function getXMLHTTPRequest() {
	var xRequest=null;
	if (window.XMLHttpRequest) {
		xRequest=new XMLHttpRequest();
	}else if (typeof ActiveXObject != "undefined"){
		xRequest=new ActiveXObject("Microsoft.XMLHTTP");
	}
	return xRequest;
}	

function sendRequest(url,HttpMethod,theForm){
	if (!HttpMethod){
		HttpMethod="POST";
	}
	var params = '';
	if(theForm){	
		var elementi = theForm.elements;
		for(i=0;i<elementi.length;i++){
			params+=elementi[i].name+'='+elementi[i].value+"&";
		}
		params = '?'+params.substring(0,params.length-1);
		alert(params);
	}
	new Ajax.Request(url,
	  {
	    method:HttpMethod,
	    onSuccess: function(transport){
	      var response = transport.responseText || "no response text";
	      $('breadCrumb').innerHTML=response;
	    },
	    onFailure: function(){ alert('Something went wrong...') },
	    parameters: params
	    
	  });
	
}



function getData(){
	var ready=req.readyState;
	var data=null;
	if (ready==READY_STATE_COMPLETE){
		data=req.responseText;
		document.getElementById('breadCrumb').innerHTML=data;
	}else{
		data="loading...["+ready+"]";
	}
//... do something with the data...
}



/********************************
Funzioni per il menu ad albero
*********************************/
function mmenu(mID) {
	var menu = document.getElementById(mID);
	var display = menu.style.display;
	menu.style.display = (display == "block") ? "none" : "block";
	menu.parentNode.style.listStyleImage = (display == "block") ? "url(cartellachiusa.gif)" : "url(cartellaaperta.gif)";
}

window.onload = function() {
	var uls = document.getElementsByTagName("ul");
	for (i=0;i<uls.length;i++) {
		if(uls[i].className=="submenu")uls[i].style.display = "none";
	}
}
